/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 */
 var FindSumPairs = function(nums1, nums2) {
    this.nums1 = nums1
    this.nums2 = nums2
};

/** 
 * @param {number} index 
 * @param {number} val
 * @return {void}
 */
FindSumPairs.prototype.add = function(index, val) {
    this.nums2[index] += val
};

/** 
 * @param {number} tot
 * @return {number}
 */
FindSumPairs.prototype.count = function(tot) {
    const {nums1, nums2} = this
    const map = new Map()
    for(let num of nums1){
        map.set(num, map.has(num) ? map.get(num)+1 : 1)
    }
    let ans = 0
    for(let i = 0; i<nums2.length; i++){
        ans += map.has(tot-nums2[i]) ? map.get(tot-nums2[i]) : 0
    }
    return ans
};

/**
 * Your FindSumPairs object will be instantiated and called as such:
 * var obj = new FindSumPairs(nums1, nums2)
 * obj.add(index,val)
 * var param_2 = obj.count(tot)
 */